<template lang="html">
  <div class="">
      <div class="header">
          <!-- <el-form class="filterCondition demo-form-inline" ref="form"  :inline="true" label-width="80px">
              <el-input placeholder="输入市代名称" v-model="keyword" style="width: 420px;">
                <el-button slot="append" style="width: 120px;" @click="search()">搜索</el-button>
              </el-input>
          </el-form> -->
      </div>
      <div class="body">
          <el-table :data="tableData.list" style="width: 100%">
              <el-table-column label="市代名称" prop="company" align="center" width=""></el-table-column>
              <el-table-column label="联系方式" prop="phone" align="center" width=""></el-table-column>
              <el-table-column label="负责人" prop="leader" align="center" width=""></el-table-column>
              <el-table-column label="提现金额" prop="putprice" align="center" width=""></el-table-column>
              <el-table-column label="申请时间" prop="create_time" align="center" width=""></el-table-column>
              <el-table-column label="操作" align="center" width="">
                <template slot-scope="scope">
                    <el-button type="text" size="small" @click="doPass(scope.row)">通过</el-button>
                    <el-button type="text" size="small" @click="doReject(scope.row)">驳回</el-button>
                </template>
              </el-table-column>
          </el-table>
      </div>

      <div class="page_box">
          <el-pagination class="page" layout="prev, pager, next"
            @current-change="search" :page-count='tableData.rows' >
          </el-pagination>
      </div>

  </div>
</template>

<script>
export default {
  data (){
    return {
      tableData:[],
      keyword:''
    }
  },
  created(){
    this.search()
  },
  methods: {
    search(page=1){
      this.tableData = []
      this.$http3.auditCashList({page}).
      then(res=>{
        this.tableData =
        res.data.code == 1?
        res.data.data: []
      })
    },
    doPass(e){
      this.$confirm("您确定要通过吗？")
      .then(_=>{
        this.$http3.cashAdopt({
          id: e.id,
          phone: e.phone,
        }).then(res=>{
          res.data.code == 1?
          this.$message.success(res.data.msg):
          this.$message.error(res.data.msg);
          this.search()
        })
      }).catch(_=>0)
    },
    doReject(e){
      this.$prompt('请输入驳回理由', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(({ value }) => {
          this.$http3.cashReject({
            id: e.id,
            gid: e.gid,
            phone: e.phone,
            reason: value,
          }).then(res=>{
            res.data.code == 1?
            this.$message.success(res.data.msg):
            this.$message.error(res.data.msg);
            this.search()
          })
        }).catch(_=>0);
    }
  }

}
</script>

<style lang="css" scoped>
/deep/ .el-input-group__append, .el-input-group__prepend{
  background-color: #3498E9;
  border: none;
  color: white;
}

.preview-img{
  display: block;
  width: 100%;
  height: 30px;
}
.header{
  margin-bottom: 10px
}
.page_box{
  text-align: center;
}
</style>
